package com.sali.b_design_pattern.g_singleton_pattern.lesson_singleton.b_lazy.b_thread_safe.staticinner;

/**
 * @description: 无锁的懒汉加载安全模式，比加锁方式性能高
 * @date: 2023/3/19 13:30.
 * @version: 1.0
 */
public class LazyInnerClassSingleton {

    /**
     * description: 构造函数私有化
     **/
    private LazyInnerClassSingleton() {
    }

    /**
     * 采用静态内部类的方式
     */
    private static class LazyInnerHolder {
        private final static LazyInnerClassSingleton LAZY_INNER_CLASS_SINGLETON = new LazyInnerClassSingleton();
    }

    /**
     * description: 通过方法暴露对象
     **/
    public static final LazyInnerClassSingleton getInstance() {
        return LazyInnerHolder.LAZY_INNER_CLASS_SINGLETON;
    }

}
